'use client'; import { useState } from 'react'; import Link from 'next/link'; import { BadgeCheck, Shield, MoreHorizontal, Pencil, Flag, Link as LinkIcon } from 'lucide-react'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'; import FollowButton from '@/app/component/FollowButton'; import NoteButton from '@/app/(main)/note/_components/NoteButton'; import { UserProfileDto } from '@/types/account/profile'; import { buildChannelUrl, formatHandle } from '@/lib/utils/channel'; import UserProfileEditDialog from './UserProfileEditDialog'; type Props = { profile: UserProfileDto; }; function formatCount(n: number): string { if (n >= 10000) return `${(n / 10000).toFixed(n >= 100000 ? 0 : 1)}만`; if (n >= 1000) return `${(n / 1000).toFixed(1)}천`; return n.toLocaleString(); } export default function UserProfileHeader({ profile }: Props) { const [editOpen, setEditOpen] = useState(false); const displayName = profile.name || profile.memberSID; const avatarInitial = (displayName.charAt(0) || '?').toUpperCase(); const handle = profile.channelHandle ? formatHandle(profile.channelHandle) : `@${profile.memberSID}`; const handleShare = async () => { const url = `${window.location.origin}/user/${profile.memberSID}`; try { await navigator.clipboard.writeText(url); alert('프로필 링크가 복사되었습니다.'); } catch { prompt('링크를 복사하세요:', url); } }; return (
{profile.bannerUrl ? ( {`${displayName} ) : (
)}
{profile.thumb ? ( {displayName} ) : ( {avatarInitial} )}
{profile.isSelf ? ( <> ) : ( <> )} 프로필 주소 복사 {!profile.isSelf && ( 신고하기 )}

{displayName} {profile.isCreator && ( )} {profile.isAdmin && ( )}

{profile.channelSID ? ( {handle} ) : ( handle )}

{formatCount(profile.followerCount)} 팔로워 {formatCount(profile.followingCount)} 팔로우 {formatCount(profile.postCount + profile.feedPostCount)} 게시물

{profile.intro && (
)}
); }